package com.itheima.redistest.autoconfigure;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.Jedis;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
@Configuration
@EnableConfigurationProperties(RedisProperties.class)
// 作用，就是创建了  RedisProperties, 允许使用 @ConfigurationProperties 注解

public class RedisAutoConfigure {

    @Bean
    public Jedis createJedis(@Autowired RedisProperties redisProperties){
        return new Jedis(redisProperties.getHost(), redisProperties.getPort());
    }
}
